package com.hmall.common.pojo;

import com.hmall.common.pojo.Item;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ItemDoc {
    private Long id;
    private String name;
    private Long price;
    private String image;
    private String category;
    private String brand;
    private Integer sold;
    private Integer commentCount;
    private boolean isAD;
    private List<String> suggestion= new ArrayList<>(2);

    //把从数据查出来的参数复制到这个es的实体类
    public ItemDoc(Item item) {
        //复制属性
        BeanUtils.copyProperties(item, this);
        //自动补全字段
        //品牌
        suggestion.add(item.getBrand());
        //分类
        suggestion.add(item.getCategory());

    }
}
